<!--
	轮播图
	author yjl
 -->
<template>
	<view class="slide-card">
		<!-- 轮播图 -->
		<u-swiper
			:list="images"
			mode="dot"
			:height="height"
			border-radius="34"
			@click="onclickSlide"
		/>
	</view>
</template>

<script>
import { getSlideCard } from '@/api/system.js'
export default {
  data() {
    return {
      height: 350,
      images: [],
      list: []
    }
  },
  created() {
    this.height = (this.$u.sys().screenWidth * 2 * 0.9 - 2) * 9 / 16
    getSlideCard()
      .then(res => {
        this.list = res
        this.images = res.map(item => item.pictureUrl)
      })
  },
  methods: {
    onclickSlide(index) {
      const card = this.list[ index ]

      /* linkType=1,小程序内跳转,linkType=2跳转webview */
      if (card.linkType === 1) {
        console.log(card)
        uni.navigateTo({
          url: card.linkUrl
        })
      } else if (card.linkType === 2) {
        this.$router.navigateToWebview(card.linkUrl)
      }
    }
  },
}
</script>

<style lang="scss" scoped>
.slide-card {
  border: 1px solid rgba(255, 255, 255, 1);
  border-radius: $radiusLarge;
}
</style>
